﻿# CMakeList.txt: self_signed_client 的 CMake 项目，在此处包括源代码并定义
# 项目特定的逻辑。
#
cmake_minimum_required(VERSION 3.10)
project(self_signed_client)

set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED True)

if(DEFINED ENV{VCPKG_ROOT})
    set(CMAKE_TOOLCHAIN_FILE "D:/vcpkg_test_ssl_libevent/vcpkg/scripts/buildsystems/vcpkg.cmake")
else()
    message(FATAL_ERROR "Please set VCPKG_ROOT environment variable to vcpkg root directory")
endif()

find_package(libevent REQUIRED)
find_package(spdlog CONFIG REQUIRED)
add_executable(self_signed_client "self_signed_client.cpp" )
target_link_libraries(self_signed_client PRIVATE libevent::core libevent::extra libevent::openssl spdlog::spdlog)

add_executable(self_signed_server self_signed_server.cpp )
target_link_libraries(self_signed_server PRIVATE libevent::core libevent::extra libevent::openssl spdlog::spdlog)

# 复制证书文件到可执行文件目录
file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/certificate/client.crt
     ${CMAKE_CURRENT_SOURCE_DIR}/certificate/client.key
     ${CMAKE_CURRENT_SOURCE_DIR}/certificate/server.crt
     ${CMAKE_CURRENT_SOURCE_DIR}/certificate/server.key
     DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
